package easy;

/**
 * @author wbdengtt
 * @date 2021/2/10 13:35
 */
public class Solution0210 {


    /**
     * 1491 去掉最低工资和最高工资后的品军工资
     * @param salary 工资
     * @return 返沪平均工资
     */
    public double average(int[] salary) {
        if (salary.length==0) {
            return 0;
        }
        if (salary.length==1) {
            return salary[0];
        }
        if (salary.length==2) {
            return (double) (salary[0]+salary[1]) / 2;
        }
        int sum = 0;
        int min = salary[0];
        int max = salary[0];

        for (int temp: salary) {
            if (min>temp) {
                min = temp;
            }
            if (max < temp) {
                max = temp;
            }
            sum = sum + temp;
        }
        sum = sum - min - max;
        return (double)sum / (salary.length-2);

    }


}
